/*-------------------<-- Start of Description-->---------------------\ | Save the current word document; | |---------------------<-- End of Description-->----------------------| |--------------------------------------------------------------------| |------------<-- Start of Files or Arguments Needed-->---------------| | Argument: | | filepath: the path of the file you want to save to; | | wordref: word reference; not necessary, default is "wordsys"; | | if a filereference is provided, the current document | | will be saved as the name provided; otherwise, it will | | save the document using the default name (the original | | file name) or a word temp name. | |-------------<-- End of Files or Arguments Needed-->----------------| |--------------------------------------------------------------------| |------------------<-- Start of Files Created-->---------------------| | Example: %wordsave(d:\www\sasmacros\temp.doc); | | Usage: %wordsave(filepath, wordref); | \-------------------<-- End of Files Created-->---------------------*/ %macro wordsave/parmbuff; /*--------------------------------------------\ | Copy Right: Duo Zhou; | | Created: 6-4-2001 8:43pm; | | Modified: 1-15-2001 10:22pm; | | Purpose: Save the word document; | \--------------------------------------------*/ %local fref wsid rc num fileref filepath wordref; %let num=1; %let fref=; %let wsid=0; %if %words(&syspbuff, dlm=%quote(,()))>1 %then %do; %let fref=%qscan(&syspbuff,-1,%str(,()''""= )); %end; %else %do; %let fref=wordsys; %end; %if (&fref ne ) %then %do; %let wsid=%sysfunc(fopen(&fref,o,132,e)); %end; %if &wsid %then %do; %let rc=%sysfunc(fclose(&wsid)); %let fileref=%qscan(&syspbuff,&num,%str((),""'')); %if &fileref ne %then %do; %if (%substr(%upcase(&fileref),%eval(%length(&fileref)-3),4) ne .DOC) %then %do; %let fileref=&fileref..doc; %end; %put --> Note: File will be saved as "&fileref". ; data _null_; file &fref lrecl=2000; length str $2000.; str='[FileSaveAs .Name = "'||trim(left("&fileref"))||'", .Format = 0, .LockAnnot = 0, .Password = "", .AddToMru = 1, .WritePassword = "", .RecommendReadOnly = 0, .EmbedFonts = 0, .NativePictureFormat = 0, .FormsData = 0]'; put str; run; %end; %else %do; data _null_; file &fref lrecl=2000; length str $2000.; str='[FileSave]'; put str; run; %end; %end; %else %do; %put ==> Alert! Incorrect window reference "&fref", or window "&fref" isn%str(%')t open.; %end; %mend wordsave;